package Servlet.Test;
/*
@ClassName:     ServletTest
@Author:        YangXu
@Need:          
@Date:          2022/4/26
@Time:          2022-04-26 10:36
*/

//


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

public class ServletTest extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取到浏览器的所有请求头
        Enumeration<String> headerNames = req.getHeaderNames();
        while (headerNames.hasMoreElements()){
            String s = headerNames.nextElement();
            String value = req.getHeader(s);
            System.out.println(s+":"+value);
        }
        System.out.println("--------");
        //获取到Servlet的路径
        String servletPath = req.getServletPath();
        System.out.println("Servlet的路径"+servletPath);
    }
}
/*

 */